package com.jaiai.work;

import com.jaiai.work.util.IdWorkUtil;
import com.jaiai.work.util.ThreadPoolProxy;
import com.jaiai.work.util.redis.RedisUtil;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
@EnableAutoConfiguration
public class ProjectApplication {

	public static void main(String[] args) {
		SpringApplication.run(ProjectApplication.class, args);
	}


	/**
	 * 配制id生成器
	 * @param redisUtil
	 * @return
	 */
	@Bean
	@ConditionalOnMissingBean(IdWorkUtil.class)//容器中如果没有RedisClient这个类,那么自动配置这个RedisClient
	public IdWorkUtil idWorkUtil(@Qualifier("rdisUtil")RedisUtil redisUtil) {
		IdWorkUtil workUtil=new IdWorkUtil(redisUtil,23);
		return workUtil;
	}

	@Bean
	@ConditionalOnMissingBean(ThreadPoolProxy.class)
	public  ThreadPoolProxy threadPoolProxy(){
		return  new ThreadPoolProxy(60,100,10000);
	}
}
